/*
 * Ethan Levine
 * 
 * The contents of this file are subject to the GNU General Public
 * License (GPL) v2.  The full contents of this license can be
 * found at Mathma's website, http://www.codeplex.com/mathma/license
 */

package mathma.core.form;

import mathma.core.expr.UnknownValueException;

import mathma.core.value.Value;
import mathma.core.value.ValueType;

/**
 * @since 0.1.3
 * @author Ethan Levine
 */
public abstract class SuspendedExpression<E extends Value, O extends Value>
        extends FormulaicExpression<E, O> {
    
    protected SuspendedExpression(ValueType<E> type) {
        super(type);
    }

    @Override
    public E evaluate() {
        try {
            return calculate().evaluate();
        } catch (UnknownSuspensionException e) {
            throw new UnknownValueException("Unknown suspension carries no value.", e);
        }
    }
}
